package symbal.mipssymbal;

import mips.Reg;
import mips.directive.Space;
import symbal.Symbal;
import symbal.Vtype;

public class MipsSymbal extends Symbal {
    private Reg regLocation;
    private Space spaceLocation;
    private int spLocation;
    private int directLocation;
    private int locationType;
    private int deadline;

    public MipsSymbal(String name, Vtype vtype) {
        super(name, vtype);
        this.locationType = -1;
    }

    public void setRegLocation(Reg reg) {
        this.regLocation = reg;
        this.locationType = 0;
    }

    public void setSpaceLocation(Space space) {
        this.spaceLocation = space;
        this.locationType = 1;
    }

    public void setSpLocation(int offset) {
        this.spLocation = offset;
        this.locationType = 2;
    }

    public void setDirectLocation(int directLocation) {
        this.directLocation = directLocation;
        this.locationType = 3;
    }

    public void setDeadline(int deadline) {
        this.deadline = deadline;
    }

    public boolean isdead(int line) {
        return line > deadline;
    }

    public Reg getRegLocation() {
        return regLocation;
    }

    public Space getSpaceLocation() {
        return spaceLocation;
    }

    public int getSpLocation() {
        return spLocation;
    }

    public int getDirectLocation() {
        return directLocation;
    }

    public boolean onReg() {
        return locationType == 0;
    }

    public boolean onData() {
        return locationType == 1;
    }

    public boolean onStack() {
        return locationType == 2;
    }

    public boolean onDirect() {
        return locationType == 3;
    }
}
